package restlet;

import model.Povlastica;
import model.Util;

import org.restlet.data.Reference;
import org.restlet.resource.ServerResource;

import restlet.interfaces.BeneffitResourceI;
import beans.BeneffitBean;

public class BeneffitResource extends ServerResource implements BeneffitResourceI{

	@Override
	public BeneffitBean getBeneffitByID() {
		System.out.println("BeneffiteResource");
		String povlasticaId = Reference.decode((String) getRequest().getAttributes().get("povlasticaId"));
		System.out.println("Pram: " + povlasticaId);
		if (povlasticaId == null) {
			return null;	
		}

		Povlastica povlastica = Util.getEntityFromTableByID(Povlastica.class, povlasticaId);

		if (povlastica == null) {
			return null;	
		}
		System.out.println("Poslato: " + povlastica.toBeneffitBean());
		return povlastica.toBeneffitBean();
	}

}
